import java.io.File;
import java.io.FileFilter;


public class SearchDir {
	public static int countDirs(String path) {
		return getDirs(new File(path)).length;
	}

	public static int countFiles(String path) {
		return getFiles(new File(path)).length;
	}

	public static File[] getDirs(File dir) {
		// This filter only returns directories
		FileFilter fileFilter = new FileFilter() {
			public boolean accept(File file) {
				if(file.getName().startsWith(".")) return false;
				return file.isDirectory();
			}
		};

		return dir.listFiles(fileFilter);
	}

	public static File[] getFiles(File dir) {
		// This filter only returns files
		FileFilter fileFilter = new FileFilter() {
			public boolean accept(File file) {
				if(file.getName().startsWith(".")) return false;
				return !file.isDirectory();
			}
		};

		return dir.listFiles(fileFilter);
	}

	public static File[] get(File dir, FileFilter filter) {
		return dir.listFiles(filter);
	}
}
